var irinori = {};

irinori.lib = {
	addClass: function( element, className ) {
		irinori.lib.removeClass( element, className );
		
		element.className = irinori.lib.trim( element.className ) + " " + className;
	},
	
	removeClass: function( element, className ) {
		var classes = irinori.lib.trim( element.className ).split(" ");
		var newClassName = "";
		
		for ( var i = 0; i < classes.length; i++ ) {
			if ( classes[i] != className ) {
				newClassName += classes[i] + " ";
			}
		}
		
		element.className = irinori.lib.trim( newClassName );
	},

	hasClass: function( element, className ) {
		var classes;

		if ( element.className ) {
			classes = irinori.lib.trim( element.className ).split(" ");
			
			for ( var i = 0; i < classes.length; i++ ) {
				if ( classes[i] == className ) {
					return true;
				}
			}
		}

		return false;
	},
	
	trim: function( string ) {
			return string.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g,'').replace(/\s+/g,' ');
	},
	
	getFirstChild: function( parent ) {
		var firstChild = parent.firstChild;
		
		while ( firstChild && firstChild.nodeType != 1 ) {
			firstChild = firstChild.nextSibling;
		}
		
		return firstChild;
	},
	
	getNextSibling: function( sibling ) {
		var nextSibling = sibling.nextSibling;
		
		while ( nextSibling && nextSibling.nodeType != 1 ) {
			nextSibling = nextSibling.nextSibling;
		}
		
		return nextSibling;
	}
};
